home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 372 < prev    next >
Internet Message Format  |  1996-08-06  |  1KB

  1. Path: senator-bedfellow.mit.edu!tada
  2. From: tada@athena.mit.edu (Michael J Zehr)
  3. Newsgroups: comp.std.c
  4. Subject: setjmp usage question
  5. Date: 24 Feb 1996 21:10:50 GMT
  6. Organization: Massachusetts Institute of Technology
  7. Message-ID: <4gnusq$7be@senator-bedfellow.MIT.EDU>
  8. NNTP-Posting-Host: carbonara.mit.edu
  9.  
  10.  
  11. I'm trying to determine whether a particular usage of setjmp is
  12. sanctioned by the standard and I'm finding a compiler bug or whether my
  13. usage is non-conforming.  My code boils down to this:
  14.  
  15. jmp_buf env[10];
  16. int env_index;
  17.  
  18. void func(int *error_code)
  19. {
  20.   env_index = 0;
  21.  
  22.   if (*error_code = setjmp(env[env_index++])) {
  23.     /* can env_index == 1 here? */
  24.     return;
  25.   }
  26.   env_index--;
  27.   longjmp(env[env_index], 1);
  28. }
  29.  
  30. Should this code work correctly?  In particular, can a compiler
  31. increment env_index after longjmp is called?
  32.  
  33. [Additional question because I'm curious:  what happens to
  34. post-increments that are in parameters of the longjmp call?  Are they
  35. ever executed?  I suppose the general question is where are the sequence
  36. points when you're using setjmp and lonjmp?]
  37.  
  38. Thanks for any help,
  39. michael j zehr
  40.  
  41.